<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <button class="btn">切换</button>

  <!-- hidden属性 -->
  <div id="box" class="cba" title="aaa" style="color: red">
    哈哈哈哈哈
  </div>
  
  <script>
    // 1.获取元素
    var boxEl = document.querySelector("#box")
    var btnEl = document.querySelector(".btn")

    // 2.监听btn的点击
    btnEl.onclick = function() {
      // 1.只是隐藏
      // boxEl.hidden = true
      // boxEl.style.display = "none"

      // 2.切换
      // boxEl.hidden = false
      // if (boxEl.hidden === false) {
      //   boxEl.hidden = true
      // } else {
      //   boxEl.hidden = false
      // }

      // 3.直接取反
      boxEl.hidden = !boxEl.hidden
    }


  </script>

</body>
</html>